import java.util.Scanner;

public class Test {
    public static void main(String[] args) {


        Scanner input = new Scanner(System.in);
        Person[] person = new Person[2];
        person[0] = new Teacher("name", "email", "address", "title");
        person[1] = new Student("name", "email", "address", "id");
        
        //信息录入
        for (int i = 0; i < person.length; i++) {
            int cpr = person[0].job(person[i]);
            if(cpr == 0){
                System.out.println("老师信息录入");
            }
            if(cpr == 1){
                System.out.println("学生信息录入");
            }
            System.out.println("输入姓名");
            String inputn = input.nextLine();
            System.out.println("输入邮箱");
            String inpute = input.nextLine();
            System.out.println("输入地址");
            String inputa = input.nextLine();
            if(cpr == 0){
                Teacher t = (Teacher) person[i];
                t.setInfo(inputn, inpute, inputa);
                t.setLoad();//写的时间有点长，我忘记前面重写了setInfo的方法了。。。
                System.out.println(t);
            }
            if(cpr == 1){
                Student s = (Student) person[i];
                s.setInfo(inputn, inpute, inputa);
                s.setLoad();
                System.out.println(s);
            }

        }
        
        
         //通讯录遍历和查询实验
        Person[] addressbook = new Person[6];
        addressbook[0] = new Teacher("ywj", "ywjjava666@sysu.edu.cn", "sysuim", "associate professor");
        addressbook[1] = new Teacher("yy", "yydalaodaiwofei@pku.cn", "sysuim", "assistant");
        addressbook[2] = new Teacher("xp", "xp99kanwoyiyan@sysu.edu.cn", "yuexiuGZ", "doctor");
        addressbook[3] = new Student("wxk", "xkissohappy@qq.com","sysul","20361071");
        addressbook[4] = new Student("fyj", "fyjbaowoxiandaiguo@11.com", "sysuim", "20361047");
        addressbook[5] = new Student("wwj", "wwjeatshit@163.com", "sysuim", "20361069");
        //遍历
        for (int i = 0; i < addressbook.length; i++) {
            System.out.println();
            System.out.println(addressbook[i]);
        }
        //以通过名字查询为例
        System.out.println("请输入查询线索");
        String searchinfo = input.nextLine();
        int flag =-1;
        for (int i = 0; i < addressbook.length; i++) {
            if(addressbook[i].nameSearch(searchinfo)){
                flag =1;
                System.out.println(addressbook[i]);
                return;
            }
        }
        if(flag ==-1){
            System.out.println("错误");
        }

    }
}


        
/*
 * System.out.println("输入管理人数"); int n = input.nextInt(); Person[] person = new
 * Person[n]; System.out.println("输入查询序号"); int m = input.nextInt(); person[m] =
 * new Student("name", "email", "address", "id"); person[m] = new
 * Teacher("name", "email", "address", "title");
 */
/*
 * if(person[m] instanceof Student){ System.out.println("输入学号"); String inputi =
 * input.nextLine(); } if(person[m] instanceof Teacher){
 * System.out.println("输入职称"); String inputt = input.nextLine();
 */
